//
//  TripsDetailPhotoTableViewCell.m
//  chanyou
//
//  Created by leon on 15/1/4.
//  Copyright (c) 2015年 wanli. All rights reserved.
//

#import "TripsDetailPhotoTableViewCell.h"
#import "Masonry.h"
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)


@implementation TripsDetailPhotoTableViewCell
- (void)dealloc
{
    [_descriptionLabel release];
    [_photoView release];
    [_locationLabel release];
    [super dealloc];
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        self.photoView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH - 20, SCREEN_HEIGHT / 3)];
        [self.contentView addSubview:_photoView];
        [_photoView release];
        
        self.descriptionLabel = [[UILabel alloc] init];
        _descriptionLabel.font = [UIFont systemFontOfSize:13];
        _descriptionLabel.numberOfLines = 0;
        _descriptionLabel.alpha = 0.85;
        [self.contentView addSubview:_descriptionLabel];
        [_descriptionLabel release];
        
//        self.locationLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, self.contentView.frame.size.height * 4 / 5, self.contentView.frame.size.width / 2, self.contentView.frame.size.width / 12)];
        self.locationLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_locationLabel];
        [_locationLabel release];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    NSDictionary *dic  = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:13.0f], NSFontAttributeName, nil];
    CGRect rect = [self.descriptionLabel.text boundingRectWithSize:CGSizeMake(self.frame.size.width, 10000) options:(NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin) attributes:dic context:nil];
    [self.descriptionLabel setFrame:CGRectMake(10, 10 + SCREEN_HEIGHT / 3, self.contentView.frame.size.width - 15, rect.size.height)];
    
    [_locationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.equalTo(_descriptionLabel).insets(UIEdgeInsetsMake(100, 0, 40, 0));
    }];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
